﻿namespace Hotel.ModulesTest
{
    using ResourcesModule = Hotel.Module.Resources;
    using Hotel.Module.Resources.Models;
    using System.Collections.Generic;
    using Hotel.Module.Management;
    using Hotel.Module.Management.Models;
    using System;
    using Hotel.Web.Controllers;
    using NUnit.Framework;
    using System.Linq;

    [TestFixture]
    class ResourcesControllerTestClass
    {
        [Test]
        public void FindPredicateTest()
        {
            Room result = null;
            int _currentRoomNumber = default(int);
            using (ResourcesModule.HotelResourcesController m_ResourcesController = Hotel.Web.Helpers.ServiceLocator.Instance.GetService(typeof(ResourcesModule.IResourseManagment)) as ResourcesModule.HotelResourcesController)
            {
                List<Room> _allRooms = m_ResourcesController.GetAllRooms();
                _currentRoomNumber = _allRooms[_allRooms.Count - 1].Number;
                result = (Room)m_ResourcesController.Storage.Find(new Predicate<Room>(r => r.Number == _currentRoomNumber));
            }
            Assert.AreEqual(_currentRoomNumber, result.Number);
        }

        [Test]
        public void EnumerateRoomsTest()
        {

            using (ResourcesModule.HotelResourcesController m_ResourcesController = Hotel.Web.Helpers.ServiceLocator.Instance.GetService(typeof(ResourcesModule.IResourseManagment)) as ResourcesModule.HotelResourcesController)
            {
                List<ResourcesModule.Models.Room> target = (List<ResourcesModule.Models.Room>)m_ResourcesController.GetAllRooms();
                Assert.AreEqual(72, target.Count);
            }

        }

        [Test]
        public void QueryRoomsTest()
        {

            using (ResourcesModule.HotelResourcesController m_ResourcesController = Hotel.Web.Helpers.ServiceLocator.Instance.GetService(typeof(ResourcesModule.IResourseManagment)) as ResourcesModule.HotelResourcesController)
            {
                List<ResourcesModule.Models.Room> target = (List<ResourcesModule.Models.Room>)m_ResourcesController.Storage.GetQuery<Room>().ToList();
                Assert.AreEqual(72, target.Count);
            }

        }
    }
}
